package cn.edu.sdjzu.xg23.kcsj01_backend.mapper;

import cn.edu.sdjzu.xg23.kcsj01_backend.controller.*;
import cn.edu.sdjzu.xg23.kcsj01_backend.service.*;
import cn.edu.sdjzu.xg23.kcsj01_backend.utils.*;
import cn.edu.sdjzu.xg23.kcsj01_backend.entity.*;
import cn.edu.sdjzu.xg23.kcsj01_backend.mapper.*;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

import java.util.List;

@Service
public class EmployeeAssPaperService {
    @Autowired
    private EmployeeAssPaperMapper employeesAsPaperMapper;
    @Autowired
    private SnowflakeIdGenerator snowflakeIdGenerator;
    public PageInfo<EmployeeAssPaper> get(int pageNum, int pageSize, EmployeeAssPaper employeeAssPaper){
        PageHelper.startPage(pageNum,pageSize);
        List<EmployeeAssPaper> employeeAssPaperList  = employeesAsPaperMapper.get(employeeAssPaper);
        return PageInfo.of(employeeAssPaperList);
    }
    public String save(EmployeeAssPaper employeeAssPaper){
        if(employeeAssPaper.getId()==null){
            Long id = snowflakeIdGenerator.generateId();
            employeeAssPaper.setId(id);
        }

        if(employeesAsPaperMapper.save(employeeAssPaper)){
            return "保存成功";
        }
        return "保存失败";
    }
    public String update(EmployeeAssPaper employeeAssPaper){
        if(employeesAsPaperMapper.update(employeeAssPaper)){
            return "修改成功";
        }
        return "修改失败";
    }
    public String delete(Long id){
        if(employeesAsPaperMapper.delete(id)){
            return "删除成功";
        }
        return "删除失败";
    }
}
